import request from '@/utils/request'

// 确认订单
// mode: cart    => obj cartIds
// mode: buyNow  => obj goodsId, goodsNum, goodsSkuId
export const checkOrder = (mode, obj) => {
  return request.get('/checkout/order', {
    params: {
      mode,
      delivery: 10, // 10快递 20自提
      couponId: 0, // 优惠券id
      isUsePoints: 0, // 是否使用积分
      ...obj
    }
  })
}
// 提交订单
// mode: cart    => obj cartIds, remark
// mode: buyNow  => obj goodsId, goodsNum, goodsSkuId, remark
export const submitOrder = (mode, obj) => {
  return request.post('/checkout/submit', {
    mode,
    delivery: 10, // 10快递 20自提
    couponId: 0, // 优惠券id
    isUsePoints: 0, // 是否使用积分
    payType: 10, // 支付方式 10余额支付
    ...obj
  })
}

// 我的订单
export const getMyOrder = (dataType, page) => {
  return request.get('/order/list', {
    params: {
      dataType,
      page
    }
  })
}
